package com.nulldev.util.string;

public class JUEscaper extends UnicodeEscaper {

    public static JUEscaper above(final int codepoint) {
        return outsideOf(0, codepoint);
    }
    
    public static JUEscaper below(final int codepoint) {
        return outsideOf(codepoint, Integer.MAX_VALUE);
    }
    
    public static JUEscaper between(final int codepointLow, final int codepointHigh) {
        return new JUEscaper(codepointLow, codepointHigh, true);
    }
    
    public static JUEscaper outsideOf(final int codepointLow, final int codepointHigh) {
        return new JUEscaper(codepointLow, codepointHigh, false);
    }
    
    public JUEscaper(final int below, final int above, final boolean between) {
        super(below, above, between);
    }
    
    @Override
    protected String toUtf16Escape(final int codepoint) {
        final char[] surrogatePair = Character.toChars(codepoint);
        return "\\u" + CharSequenceTranslator.hex(surrogatePair[0]) + "\\u" + CharSequenceTranslator.hex(surrogatePair[1]);
    }
}
